home *** CD-ROM | disk | FTP | other *** search
/ How Many Bugs in a Box / How Many Bugs in a Box.cdr / bugs / act2 / 00250.ls < prev    next >
Encoding:
Text File  |  1995-03-28  |  12.1 KB  |  357 lines

  1. on swapme
  2.   global myclick, cx, cy, total
  3.   set myclick to the clickOn
  4.   set cx to the locH of sprite the clickOn
  5.   set cy to the locV of sprite the clickOn
  6.   if (the clickOn < 21) and (the clickOn > 10) then
  7.     set the castNum of sprite 33 to the castNum of sprite the clickOn
  8.     set the locV of sprite myclick to -200
  9.     moveme()
  10.     if sprite 33 within 3 then
  11.       set the locH of sprite myclick to the locH of sprite 33
  12.       set the locV of sprite myclick to the locV of sprite 33
  13.       set the locV of sprite 33 to -200
  14.       set total to total + 1
  15.     else
  16.       if sprite 33 intersects 3 and not (sprite 33 within 3) then
  17.         smove(33, 30, cx, cy)
  18.         set the locH of sprite myclick to cx
  19.         set the locV of sprite myclick to cy
  20.         set the locV of sprite 33 to -200
  21.       else
  22.         set the locH of sprite myclick to the mouseH
  23.         set the locV of sprite myclick to the mouseV
  24.         set the locV of sprite 33 to -200
  25.         updateStage()
  26.       end if
  27.     end if
  28.   end if
  29. end
  30.  
  31. on swapme2
  32.   global myclick, cx, cy, mysound, bugsounds
  33.   set myclick to the clickOn
  34.   set cx to the locH of sprite the clickOn
  35.   set cy to the locV of sprite the clickOn
  36.   if (the clickOn < 21) and (the clickOn > 10) then
  37.     set the castNum of sprite 33 to the castNum of sprite the clickOn
  38.     set the locH of sprite 33 to cx
  39.     set the locV of sprite 33 to cy
  40.     set the locV of sprite myclick to -200
  41.     set mysound to getAt(bugsounds, myclick - 10)
  42.   end if
  43. end
  44.  
  45. on moveme2
  46.   global myclick, cx, cy, total, toplimit, bottomlimit, rightlimit, leftlimit, bugstatus, stopbugs, gobugs, athome
  47.   set loch33 to the locH of sprite 33
  48.   set locv33 to the locV of sprite 33
  49.   if sprite 33 intersects 48 then
  50.     smove(33, 30, cx, cy)
  51.     set the locH of sprite myclick to cx
  52.     set the locV of sprite myclick to cy
  53.     set the locV of sprite 33 to -200
  54.   else
  55.     if sprite 3 intersects 33 then
  56.       set the locH of sprite myclick to loch33
  57.       set the locV of sprite myclick to locv33
  58.       set the castNum of sprite myclick to getAt(stopbugs, myclick - 10)
  59.       setAt(bugstatus, myclick - 10, 1)
  60.       set the locV of sprite 33 to -200
  61.       set total to total + 1
  62.       sortthem()
  63.     else
  64.       set the locH of sprite myclick to loch33
  65.       set the locV of sprite myclick to locv33
  66.       set the castNum of sprite myclick to getAt(gobugs, myclick - 10)
  67.       setAt(bugstatus, myclick - 10, 0)
  68.       set the locV of sprite 33 to -200
  69.       if getPos(athome, myclick) > 0 then
  70.         deleteAt(athome, getPos(athome, myclick))
  71.       end if
  72.       sortthem()
  73.     end if
  74.   end if
  75.   puppetSound(0)
  76.   go("presto")
  77. end
  78.  
  79. on nextnum
  80.   global numberlist
  81.   if numberlist = [] then
  82.     set templist to [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  83.     set numberlist to []
  84.     repeat with xxx = 1 to 10
  85.       set holdme to getAt(templist, random(count(templist)))
  86.       add(numberlist, holdme)
  87.       deleteAt(templist, getPos(templist, holdme))
  88.     end repeat
  89.   end if
  90.   set wnum to getAt(numberlist, random(count(numberlist)))
  91.   deleteAt(numberlist, getPos(numberlist, wnum))
  92.   return wnum
  93. end
  94.  
  95. on correctbugs
  96.   global bugstatus, gametwolevel, wnum, bugcount, origcoord, boxcenter, boxgrid, gobugs, stopbugs
  97.   set boxbot to the bottom of sprite 3
  98.   set boxtop to the top of sprite 3
  99.   set boxleft to the left of sprite 3
  100.   set boxright to the right of sprite 3
  101.   set totbugs to 0
  102.   repeat with xxx = 1 to 10
  103.     if getAt(bugstatus, xxx) = 1 then
  104.       set totbugs to totbugs + 1
  105.     end if
  106.   end repeat
  107.   if bugcount = "lessthan" then
  108.     set xxx to 1
  109.     repeat while totbugs < wnum
  110.       if getAt(bugstatus, xxx) = 0 then
  111.         set thissprite to xxx + 10
  112.         set changeh to (getAt(getAt(boxgrid, xxx), 1) - the locH of sprite thissprite) / 5.0
  113.         set changev to (getAt(getAt(boxgrid, xxx), 2) - the locV of sprite thissprite) / 5.0
  114.         repeat with yyy = 1 to 5
  115.           set the locH of sprite thissprite to the locH of sprite thissprite + changeh
  116.           set the locV of sprite thissprite to the locV of sprite thissprite + changev
  117.           updateStage()
  118.         end repeat
  119.         set the castNum of sprite thissprite to getAt(stopbugs, thissprite - 10)
  120.         set the locH of sprite thissprite to getAt(getAt(boxgrid, xxx), 1)
  121.         set the locV of sprite thissprite to getAt(getAt(boxgrid, xxx), 2)
  122.         set myl to boxleft - the left of sprite thissprite
  123.         set myt to boxtop - the top of sprite thissprite
  124.         set myr to the right of sprite thissprite - boxright
  125.         set myb to the bottom of sprite thissprite - boxbot
  126.         if not (sprite thissprite within 3) then
  127.           if 0 <= myl then
  128.             set the locH of sprite thissprite to the locH of sprite thissprite + (myl + 10)
  129.           end if
  130.           if 0 <= myt then
  131.             set the locV of sprite thissprite to the locV of sprite thissprite + (myt + 10)
  132.           end if
  133.           if 0 <= myr then
  134.             set the locH of sprite thissprite to the locH of sprite thissprite - (myr + 10)
  135.           end if
  136.           if 0 <= myb then
  137.             set the locV of sprite thissprite to the locV of sprite thissprite - (myb + 10)
  138.           end if
  139.           updateStage()
  140.         end if
  141.         setAt(bugstatus, xxx, 1)
  142.         set totbugs to totbugs + 1
  143.       end if
  144.       set xxx to xxx + 1
  145.     end repeat
  146.     sortthem()
  147.   else
  148.     set xxx to 1
  149.     repeat while totbugs > wnum
  150.       if getAt(bugstatus, xxx) = 1 then
  151.         set thissprite to xxx + 10
  152.         set changeh to (getAt(getAt(origcoord, xxx), 1) - the locH of sprite thissprite) / 5
  153.         set changev to (getAt(getAt(origcoord, xxx), 2) - the locV of sprite thissprite) / 5
  154.         repeat with yyy = 1 to 5
  155.           set the locH of sprite thissprite to the locH of sprite thissprite + changeh
  156.           set the locV of sprite thissprite to the locV of sprite thissprite + changev
  157.           updateStage()
  158.         end repeat
  159.         set the castNum of sprite thissprite to getAt(gobugs, thissprite - 10)
  160.         setAt(bugstatus, xxx, 0)
  161.         set totbugs to totbugs - 1
  162.       end if
  163.       set xxx to xxx + 1
  164.     end repeat
  165.   end if
  166. end
  167.  
  168. on bugsetup
  169.   global wnum, TRIAL, total, numberlist, gametwolevel, direction, rightsprite, gobugs, stopbugs, numbercast, rednumcast, panelcast, bfcast, bgcast, gocast, stopcast, saybottombox, dupnumbers, bugsounds, athome
  170.   set total to 0
  171.   set TRIAL to 0
  172.   set athome to []
  173.   set rightsprite to 0
  174.   if gametwolevel = 1 then
  175.     puppetSprite(42, 1)
  176.     set wnum to nextnum()
  177.     if wnum = 1 then
  178.       set the castNum of sprite 42 to getAt(panelcast, 2)
  179.     else
  180.       set the castNum of sprite 42 to getAt(panelcast, 1)
  181.     end if
  182.     set saybottombox to "put " & wnum
  183.     puppetSprite(47, 1)
  184.     set the castNum of sprite 47 to getAt(numbercast, wnum + 1)
  185.     set the locH of sprite 47 to 254
  186.   else
  187.     if gametwolevel = 2 then
  188.       set direction to 2
  189.       if random(100) > 50 then
  190.         set wnum to nextnum()
  191.         set othernum to nextnum()
  192.         repeat while wnum = othernum
  193.           set othernum to nextnum()
  194.         end repeat
  195.         puppetSprite(42, 1)
  196.         set the castNum of sprite 42 to getAt(panelcast, 4)
  197.         puppetSprite(45, 1)
  198.         set the locH of sprite 45 to 495
  199.         set the castNum of sprite 45 to getAt(dupnumbers, wnum * 2)
  200.         puppetSprite(46, 1)
  201.         set the locH of sprite 46 to 495
  202.         set the castNum of sprite 46 to getAt(dupnumbers, (othernum * 2) - 1)
  203.         puppetSprite(47, 1)
  204.         set the locH of sprite 47 to 595
  205.         set the castNum of sprite 47 to 26
  206.         set saybottombox to "Level 2.2 What's Next"
  207.       else
  208.         set direction to 1
  209.         set wnum to nextnum()
  210.         repeat while wnum = 10
  211.           set wnum to nextnum()
  212.         end repeat
  213.         puppetSprite(42, 1)
  214.         set the castNum of sprite 42 to getAt(panelcast, 3)
  215.         puppetSprite(45, 1)
  216.         set the locH of sprite 45 to 379
  217.         set the castNum of sprite 45 to getAt(numbercast, wnum)
  218.         puppetSprite(46, 1)
  219.         set the locH of sprite 46 to 465
  220.         set the castNum of sprite 46 to getAt(numbercast, wnum + 2)
  221.         puppetSprite(47, 1)
  222.         set the locH of sprite 47 to 422
  223.         set the castNum of sprite 47 to 26
  224.         set saybottombox to "Level 2.1 What's missing"
  225.       end if
  226.     else
  227.       if gametwolevel = 3 then
  228.         set lev3list to []
  229.         if random(100) > 50 then
  230.           set numofchoices to 3
  231.           set suffix to "est"
  232.         else
  233.           set numofchoices to 2
  234.           set suffix to "er"
  235.         end if
  236.         repeat with xxx = 1 to numofchoices
  237.           set zoome to nextnum()
  238.           if not (getPos(lev3list, zoome) = 0) then
  239.             repeat while not (getPos(lev3list, zoome) = 0)
  240.               set zoome to nextnum()
  241.             end repeat
  242.           end if
  243.           add(lev3list, zoome)
  244.         end repeat
  245.         if random(100) > 50 then
  246.           set direction to "small" & suffix
  247.           set wnum to min(lev3list)
  248.           puppetSprite(42, 1)
  249.           set the castNum of sprite 42 to getAt(panelcast, 5 + numofchoices)
  250.         else
  251.           set direction to "larg" & suffix
  252.           set wnum to max(lev3list)
  253.           puppetSprite(42, 1)
  254.           set the castNum of sprite 42 to getAt(panelcast, 3 + numofchoices)
  255.         end if
  256.         set saybottombox to "Level 3 Put " & direction
  257.         set rightsprite to 44 + getPos(lev3list, wnum)
  258.         if numofchoices = 2 then
  259.           puppetSprite(45, 1)
  260.           set the castNum of sprite 45 to getAt(numbercast, getAt(lev3list, 1) + 1)
  261.           set the locH of sprite 45 to 515
  262.           puppetSprite(46, 1)
  263.           set the castNum of sprite 46 to getAt(numbercast, getAt(lev3list, 2) + 1)
  264.           set the locH of sprite 46 to 589
  265.           puppetSprite(47, 0)
  266.         else
  267.           puppetSprite(45, 1)
  268.           set the castNum of sprite 45 to getAt(numbercast, getAt(lev3list, 1) + 1)
  269.           set the locH of sprite 45 to 505
  270.           puppetSprite(46, 1)
  271.           set the castNum of sprite 46 to getAt(numbercast, getAt(lev3list, 2) + 1)
  272.           set the locH of sprite 46 to 599
  273.           puppetSprite(47, 1)
  274.           set the castNum of sprite 47 to getAt(numbercast, getAt(lev3list, 3) + 1)
  275.           set the locH of sprite 47 to 552
  276.         end if
  277.       end if
  278.     end if
  279.   end if
  280.   set gobugs to []
  281.   set stopbugs to []
  282.   set bugsounds to []
  283.   puppetSprite(33, 1)
  284.   repeat with bugs = 11 to 20
  285.     if bugs < 16 then
  286.       set meme to random(5)
  287.       set dacast to getAt(bgcast, meme)
  288.       add(bugsounds, "walk" & meme)
  289.     else
  290.       set meme to random(8)
  291.       set dacast to getAt(bfcast, meme)
  292.       add(bugsounds, "fly" & meme)
  293.     end if
  294.     add(gobugs, dacast)
  295.     add(stopbugs, getAt(stopcast, getPos(gocast, dacast)))
  296.     puppetSprite(bugs, 1)
  297.     set the castNum of sprite bugs to dacast
  298.     set the visible of sprite bugs to 1
  299.   end repeat
  300. end
  301.  
  302. on showspit
  303.   global bugstatus
  304.   set dalist to []
  305.   repeat with xxx = 11 to 20
  306.     add(dalist, list(the locH of sprite xxx, the locV of sprite xxx))
  307.   end repeat
  308.   put dalist
  309. end
  310.  
  311. on countbugs
  312.   global bugstatus, mysound
  313.   set mylist to []
  314.   repeat with xxx = 1 to 10
  315.     if getAt(bugstatus, xxx) = 1 then
  316.       add(mylist, 1000 + the locV of sprite (xxx + 10) & "," & 1000 + the locH of sprite (xxx + 10) & "," & xxx + 10)
  317.     end if
  318.   end repeat
  319.   sort(mylist)
  320.   set limit to count(mylist)
  321.   repeat with xxx = 1 to limit
  322.     set dasprite to value(item 3 of getAt(mylist, xxx))
  323.     set holdbcol to the backColor of sprite dasprite
  324.     set holdfcol to the foreColor of sprite dasprite
  325.     set holdink to the ink of sprite dasprite
  326.     set the ink of sprite dasprite to 8
  327.     set the foreColor of sprite dasprite to 215
  328.     set the backColor of sprite dasprite to 255
  329.     set mysound to "say" & xxx
  330.     play frame "play audio"
  331.     set the backColor of sprite dasprite to holdbcol
  332.     set the foreColor of sprite dasprite to holdfcol
  333.     set the ink of sprite dasprite to holdink
  334.   end repeat
  335.   updateStage()
  336. end
  337.  
  338. on flashme
  339.   global gametwolevel
  340.   if gametwolevel = 2 then
  341.     set holdvis to the visible of sprite 47
  342.     set holdvis to not holdvis
  343.     put holdvis
  344.     set the visible of sprite 47 to holdvis
  345.   end if
  346. end
  347.  
  348. on getbugsound
  349.   global bugsounds
  350.   if bugsounds = [] then
  351.     set bugsounds to ["spin/wb10", "bees1", "cricket"]
  352.   end if
  353.   set mybug to getAt(bugsounds, random(count(bugsounds)))
  354.   deleteAt(bugsounds, getPos(bugsounds, mybug))
  355.   return mybug
  356. end
  357.